<?php
class CollectGetAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}

	public function execute()
	{
		$tmp		= C('ToolService')->request('Post','Get',array('pid'=>$this->context->get('id')));
		
		if($tmp===false)
		{
			$this->code	= 400;
			$this->message = '请求出错，请重新尝试！';
		}
		else
		{
			$this->code		= $tmp['code'];
			$this->message	= $tmp['message'];
			if($this->code==403)
			{
				$this->message = '只有VIP用户才能使用该功能！';
			}
			else if($this->code==200)
			{
				if(!empty($tmp['data']))
				{
					$now	= date('Y-m-d H:i:s');
					$id		= C('PostService')->add(array('username'=>'淘宝买家','type'=>1,'title'=>$tmp['data']['data']['title'],'content'=>array('content'=>$tmp['data']['data']['content']),'modified'=>$now,'status'=>1,'last_updated'=>$now));
					if($id>0)
					{
						$this->code	= 200;
					}
					else
					{
						$this->code	= 500;
					}
				}
			}
		}
	}
}
